from selenium import webdriver
from selenium.webdriver.common.by import By
import time


driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://www.baidu.com")
time.sleep(2)

# 输入坚果
driver.find_element(By.ID, "kw").send_keys("坚果")
# 点击-百度一下
driver.find_element(By.ID, "su").click()
time.sleep(2)

# # js实现页面下拉
# for i in range(1, 6):
#     js = "window.scrollTo(0,{})".format(i*200)
#     # 执行js代码
#     driver.execute_script(js)
#     time.sleep(1)

# js实现页面下拉
for i in range(1, 6):
    js = "document.documentElement.scrollTop={}".format(i*200)
    # 执行js代码
    driver.execute_script(js)
    time.sleep(1)


driver.quit()